import { createSlice } from '@reduxjs/toolkit'

interface PersonnelState {
  employees: any[]
  departments: any[]
  loading: boolean
  error: string | null
}

const initialState: PersonnelState = {
  employees: [],
  departments: [],
  loading: false,
  error: null,
}

const personnelSlice = createSlice({
  name: 'personnel',
  initialState,
  reducers: {
    setEmployees: (state, action) => {
      state.employees = action.payload
    },
    setDepartments: (state, action) => {
      state.departments = action.payload
    },
  },
})

export const { setEmployees, setDepartments } = personnelSlice.actions
export default personnelSlice.reducer
